package com.xb.p16_action_data;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void send(View view){
        Intent intent=null;
        RadioGroup radioGroup=findViewById(R.id.radio_group);
        switch(radioGroup.getCheckedRadioButtonId()){
            case R.id.baidu:
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
                break;
            case R.id.call://直接拨打电话，需要权限，且需要在设备上允许应用权限：CALL_PHONE
                intent=new Intent(Intent.ACTION_CALL, Uri.parse("tel:18829532971"));
                break;
            case R.id.dial://跳转到拨号界面
                intent=new Intent(Intent.ACTION_DIAL, Uri.parse("tel://18829532971"));
                break;
            case R.id.geo1://跳转到地图界面
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse("geo:104.139,30.674"));
                break;
            case R.id.geo2://跳转到地图界面
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=query"));
                break;
            case R.id.camera://跳转到地图界面
                intent=new Intent("android.media.action.IMAGE_CAPTURE");
                break;
            case R.id.contact1://跳转到地图界面
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/"));
                break;
            case R.id.contact2://跳转到地图界面
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/1/"));
                break;
        }
        if(intent != null){
            startActivity(intent);
        }
    }
}


